﻿using System;
using System.Collections.Generic;
using TallyBook.DAL.Repository;
using TallyBook.DAL.Repository.Imp;

namespace TallyBook.BLL.Service.Imp
{
    public class IncomeService : IIncomeService<Income>
    {
        private readonly IRepository<Income> _repository = RepositoryFactory<Income>.Instance.CreatRepository();


        public Income Get(long id)
        {
            return _repository.Get(id);
        }

        public List<Income> GetAll()
        {
            return _repository.GetAll();
        }

        public int Insert(long cbbincometypeid, long cbbaccounttypeid, long id,
            decimal money, string comment, DateTime time)
        {
            var income = new Income
            {
                Id = id,
                IncomeTypeId = cbbincometypeid,
                AccountTypeId = cbbaccounttypeid,
                Money = money,
                Comment = comment,
                CreateTime = time
            };
            return _repository.Insert(income);
        }


        public int Delete(long entity)
        {
            var income = new Income
            {
                Id = entity
            };
            return _repository.Delete(income);
        }

        public int Update(long incometypeid, long id, decimal money, string comment, DateTime time)
        {
            var incomes = new Income
            {
                IncomeTypeId = incometypeid,
                Id = id,
                Money = money,
                Comment = comment,
                CreateTime = time
            };
            return _repository.Update(incomes);
        }

        public List<Income> GetDim(long incomesource)
        {
            IncomeRepository incomeTypeRepository = RepositoryFactory<Income>.Instance.IncomeTypeRepository();
            return incomeTypeRepository.GetDim(incomesource);
        }

        public List<Income> GetDim(decimal incomesource)
        {
            IncomeRepository incomeTypeRepository = RepositoryFactory<Income>.Instance.IncomeTypeRepository();
            return incomeTypeRepository.GetDim(incomesource);
        }

        public List<IncomeType> GetName()
        {
            IncomeRepository incomeTypeRepository = RepositoryFactory<IncomeType>.Instance.IncomeTypeRepository();
            return incomeTypeRepository.GetName();
        }
    }
}